package configuration;

import database.DBContext;
import database.IDBContext;
import factories.*;
import handlers.Authentificator;
import handlers.FileInfoHandler;
import handlers.IAuthentificator;
import handlers.IFileInfoHandler;
import overclocking.container.ContainerBase;
import overclocking.container.IContainer;
import play.Logger;
import serialization.IXmlSerializer;
import serialization.XmlSerializer;

public class FrontContainer extends ContainerBase {
    private static IContainer instance;

    public synchronized static IContainer getInstance() {
        if (instance == null)
            instance = new FrontContainer();
        return instance;
    }

    public FrontContainer() {
        super();
    }

    @Override
    protected void configure() {
        Logger.info("Running container configuration.");
        addImpl(IDBContext.class, DBContext.create());

        addImpl(IPlotFactory.class, new PlotFactory());

        addImpl(IAuthentificator.class, new Authentificator(this));
        addImpl(IFileInfoHandler.class, new FileInfoHandler(this));
        addImpl(IXmlSerializer.class, new XmlSerializer());

        addImpl(IStatisticsFactory.class, new StatisticsFactory());
        addImpl(IFileInfoFactory.class, new FileInfoFactory());
        Logger.info("Container configured.");
    }
}
